package com.longer.demo.framework.error;

/**
 * @program: demo
 * @description: 包装器业务异常类实现
 * @author: SunBiaoLong
 * @create: 2019-01-11 13:05
 **/
public class BusinessException extends Exception implements CommonError {
	private CommonError commonError;

	/**
	 * 直接接受BusinessError的传参  用于构造业务异常
	 * @param commonError
	 */
	public BusinessException(CommonError commonError) {
		super();
		this.commonError = commonError;
	}

	/**
	 * 接受自定义的errorMsg
	 * @param commonError
	 * @param errorMsg
	 */

	public BusinessException(CommonError commonError,String errorMsg){
		super();
		this.commonError = commonError;
		commonError.setErrorMsg(errorMsg);
	}

	@Override
	public int getErrorCode() {
		return commonError.getErrorCode();
	}

	@Override
	public String getErrorMsg() {
		return commonError.getErrorMsg();
	}

	@Override
	public CommonError setErrorMsg(String errorMsg) {
		commonError.setErrorMsg(errorMsg);
		return this;
	}
}
